#include "BubbleController.h"

BubbleController::BubbleController()
{
}

BubbleController::~BubbleController()
{
}

void BubbleController::init()
{
    // model.init();
    view.create();
}

void BubbleController::onViewLoad()
{

    // view.create();
    view.load();
    updateTimer = lv_timer_create(
        [](lv_timer_t *timer)
        {
            BubbleController *controller = (BubbleController *)timer->user_data;
            controller->update(); // get the time
        },
        100,
        this);


}

void BubbleController::onViewDisappear()
{
    deleteTimer();
    view.delVectb();
    // model.speaker.mute();
    // view.destroy();
    // model.deinit();
}

void BubbleController::update()
{
    lv_obj_invalidate(view.ui.game_station);
}


void BubbleController::deleteTimer()
{
    if (updateTimer != NULL)
    {
        lv_timer_del(updateTimer);
        updateTimer = NULL;
    }

}